<?php $this->lang->load('userauth', $this->session->userdata('ua_language')); ?>

<h2 id="playtime" style="display:block;"><?= $this->lang->line('ua_manage_title'); ?></h2>
<div id="control_area">
	<h3><a href="javascript:toggleUsers();"><?= $this->lang->line('ua_manage_user'); ?></a></h3>
	<?php if (isset($msg)) { echo "<p class=\"error\" id=\"msg\">$msg</p>"; } ?>
	<div id="usersholder">
		<?= anchor ('admin/usergroups/addUser', $this->lang->line('ua_adduser'), 
													array('class' => 'addButton'));?>
		<div id="addUser" style="display: none;">
			<form id="add_user" name="add_user" method="post" 
					action="<?= site_url('admin/usergroups/addUser');?>">
				<label for="nomo"><?= $this->lang->line('ua_username'); ?></label>
				<input name="nomo" type="text" id="nomo" size="30" />
				<br />
				<label for="select"><?= $this->lang->line('ua_group'); ?></label>
				<select name="grupo" id="select">
					<?php foreach ($listAllGroups->result() as $group): ?>
						<option value="<?= $group->grup_id;?>">
							<?= $group->grupnomo;?>
						</option>
					<?php endforeach; ?>
				</select>
				<br />
				<label for="retposxto"><?=$this->lang->line('ua_email');?></label>
				<input name="retposxto" type="text" id="retposxto" size="30" />
				<br />
				<label for="pasvorto"><?=$this->lang->line('ua_password');?></label>
				<input name="pasvorto" type="text" id="pasvorto" size="30" />
				<br />
				<input type="hidden" name="cxuaktiva" value="1" id="cxuaktiva" />
				<input type="submit" value="Add User" />
			</form>
		</div>
		<table class="stripe" id="users_table">
			<tr>
				<th><?= $this->lang->line('ua_username'); ?></th>
				<th><?= $this->lang->line('ua_group'); ?></th>
				<th><?= $this->lang->line('ua_email'); ?></th>
				<th><?= $this->lang->line('ua_enabled'); ?></th>
				<th>&nbsp;</th>
			</tr>
			<?php foreach ($listAllUsers->result() as $user): ?>
			<tr>
				<td class="username"><?= $user->nomo; ?></td>
				<td class="groupname"><?= $user->grupnomo; ?></td>
				<td class="email"><?= mailto($user->retposxto, $user->retposxto); ?></td>
				<td class="enabled"><?= ($user->cxuaktiva)? 
					$this->lang->line('ua_yes'):$this->lang->line('ua_no'); ?></td>
				<td class="edit_delete" nowrap="nowrap">
					<?= anchor ('admin/usergroups/editUser/'.$user->uz_id, 
						$this->lang->line('ua_edit'));?>
					<?= anchor ('admin/usergroups/removeUser/'.$user->uz_id, 
						$this->lang->line('ua_remove'));?></td>
			</tr>
			<?php endforeach; ?>
		</table>
	</div>
	<h3><a href="javascript:toggleGroups();"><?= $this->lang->line('ua_manage_group'); ?></a></h3>
	<?php
		if (isset($groupmsg)) {
			echo "<p class=\"error\" id=\"groupmsg\">$groupmsg</p>";
		}
	?>

	<div id="groupsholder" style="display:block;">
		<?= anchor ('admin/usergroups/addgroup', 
			$this->lang->line('ua_addgroup'), array('class' => 'addButton'));?>
		<table class="stripe">
			<tr>
				<th><?= $this->lang->line('ua_group'); ?></th>
				<th><?= $this->lang->line('ua_description'); ?></th>
				<th>&nbsp;</th>
			</tr>
			<?php foreach ($listAllGroups->result() as $group): ?>
			<tr>
				<td><?= $group->grupnomo;?></td>
				<td><?= $group->priskribo;?></td>
				<td class="edit_delete" nowrap="nowrap">
					<?= anchor ('admin/usergroups/editgroup/'.$group->grup_id, 
						$this->lang->line('ua_edit'));?>
 					<?= anchor ('admin/usergroups/removegroup/'.$group->grup_id, 
						$this->lang->line('ua_remove'));?>
				</td>
			</tr>
			<?php endforeach; ?>
		</table>
	</div>
</div>